package com.qiyue.admin.entity.base;

import com.alibaba.fastjson.annotation.JSONField;
import com.qiyue.admin.entity.base.group.GroupLeader;
import com.qiyue.admin.entity.base.group.GroupMember;
import com.qiyue.orm.jpa.model.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import net.minidev.json.annotate.JsonIgnore;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import java.util.List;

/**
 * Created with Intellij IDEA.
 * User : Yebinghuan
 * Created on 2018/1/23.
 * Description :
 */
@Entity
@Table(name="base_user")
@ApiModel("用户信息表")
public class User extends BaseEntity {

//    //姓名
//    @ApiModelProperty(value = "姓名")
//    private String userName;


    private String name;
    //密码
    @ApiModelProperty(value = "密码")
    private String password;
    //账号
    @NotBlank(message="账号不能为空！")
    private String account;
    //生日
    @ApiModelProperty(value = "生日")
    private String birthday;

    @ApiModelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "移动电话")
    private String mobilePhone;

    @ApiModelProperty("固定电话")
    private String telPhone;
    @ApiModelProperty("邮箱")
    private String email;
    @ApiModelProperty("性别")
    private String sex;
    @ApiModelProperty("用户类型")
    private String type;
    @ApiModelProperty("用户描述")
    private String description;


//    @Column(name = "user_name",length = 32)
//    public String getUsername() {
//        return userName;
//    }
//
//    public void setUsername(String userName) {
//        this.userName = userName;
//    }


    @Column(name = "account",length = 32)
    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    @Column(name = "password",length = 32)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "birthday",length = 32)
    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    @Column(name = "address",length = 100)
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "mobile_phone",length = 32)
    public String getMobilePhone() {
        return mobilePhone;
    }

    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }
    @Column(name = "tel_phone",length = 32)
    public String getTelPhone() {
        return telPhone;
    }

    public void setTelPhone(String telPhone) {
        this.telPhone = telPhone;
    }
    @Column(name = "email",length = 32)
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
    @Column(name = "sex",length = 4)
    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
    @Column(name = "type",length = 4)
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "description",length = 255)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name = "name" , length = 32)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", account='" + account + '\'' +
                ", birthday='" + birthday + '\'' +
                ", address='" + address + '\'' +
                ", mobilePhone='" + mobilePhone + '\'' +
                ", telPhone='" + telPhone + '\'' +
                ", email='" + email + '\'' +
                ", sex='" + sex + '\'' +
                ", type='" + type + '\'' +
                ", description='" + description + '\'' +
                '}';
    }


    @ApiModelProperty(value = "一对多的关系")
    private List<GroupMember> groupMember;


    @OneToMany(fetch = FetchType.LAZY , mappedBy = "user" )
    @JSONField(serialize = false)
    @com.fasterxml.jackson.annotation.JsonIgnore
    public List<GroupMember> getGroupMember() {
        return groupMember;
    }

    public void setGroupMember(List<GroupMember> groupMember) {
        this.groupMember = groupMember;
    }

    @ApiModelProperty(value = "一对多的关系")
    private List<GroupLeader> groupLeader;

    @OneToMany( fetch = FetchType.LAZY , mappedBy = "user" )
    @JSONField(serialize = false)
    @com.fasterxml.jackson.annotation.JsonIgnore
    public List<GroupLeader> getGroupLeader() {
        return groupLeader;
    }

    public void setGroupLeader(List<GroupLeader> groupLeader) {
        this.groupLeader = groupLeader;
    }
}
